package com.unknow.first.dapp.admin.account.mapper;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @TableName t_address_account_detail
 */
@TableName(value = "t_address_account_detail")
@Data
@EqualsAndHashCode
@ToString
public class AddressAccountDetail implements Serializable {

    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Long addressAccountDetailId;

    private Long referId;


    /**
     * 地址
     */
    private String address;

    /**
     * 币种id
     */
    private Integer coinId;

    /**
     * 简称
     */
    private String coinSymbol;

    /**
     * 名称
     */
    private String coinName;

    /**
     * 交易金额，可正可负
     */
    private BigDecimal amount;

    /**
     * 交易类型
     */
    private Integer tradeType;

    /**
     * 交易类型i18n，用于前台的国际化
     */
    private String tradeTypeI18n;

    /**
     * 备注
     */
    private String remark;

    private String transHash;

    /**
     * 10：结算中 20：结算完成 30：结算出错
     */
    private Integer status;

    /**
     *
     */
    private String createdBy;

    /**
     *
     */
    private Date createdDate;

    /**
     *
     */
    private String updatedBy;

    /**
     *
     */
    private Date updatedDate;

    /**
     * 交易金额，可正可负
     */
    @TableField(exist = false)
    private BigDecimal sumOfAmount;

    private String orderNo;
    /**
     *
     */
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private String payBy;


    /**
     *
     */
    @TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private String payTo;

    private Integer isShow;


    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    @TableField(exist = false)
    private JSONObject remarkJson;

    public <T> T getRemarkValue(String key) {
        if (!StringUtils.hasLength(remark)) {
            return null;
        }

        if (remarkJson == null) {
            remarkJson = JSON.parseObject(remark);
        }

        return (T) remarkJson.get(key);


    }


}